﻿// ===============================================================================
// Project Name        :    ResourcesFile4DotNet
// Project Description :   
// ===============================================================================
// Class Name          :    ResourcesFile4DotNet
// Class Version       :    v1.0.0.1
// Class Description   :    资源文件处理程序的简单版本，资源、程序、生成的资源文件都在
//                          同一目录下
//                          优点：简单，鼠标一点即可生成
//                          缺点：没有图形化界面，不能满足更多需求
// Author              :    HUANGKX 小飞兔
// Create Time         :    2018/1/18 15:26:01
// Update Time         :    2018/1/19 9:45:15
// ===============================================================================
// Copyright 2018 HUANGKX 小飞兔 . 
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ===============================================================================

using System.Drawing;
using System.IO;
using System.Resources;

namespace ResourcesFile4DotNet
{
    class Program
    {
        static void Main(string[] args)
        {
            //Resources资源文件的文件名（和exe同级目录）
            ResourceWriter rw = new ResourceWriter("ResourcesFile4DotNet.resources");

            //处理程序所在目录，也是资源文件的目录
            string str = System.AppDomain.CurrentDomain.BaseDirectory;
            DirectoryInfo dirInfo = new DirectoryInfo(str);
            //以png为例，也可以添加其他图片
            FileInfo[] files = dirInfo.GetFiles("*.png");
            foreach (FileInfo file in files)
            {
                Image img = Image.FromFile(file.FullName);

                //添加到资源文件中（资源名称中会将后缀名去掉）
                rw.AddResource(Path.GetFileNameWithoutExtension(file.Name), img);
            }

            //执行生成
            rw.Generate();
            rw.Close();
        }
    }
}
